package com.bawei.hgshop.service.impl;

import java.util.List;

import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import com.bawei.hgshop.entity.Brand;
import com.bawei.hgshop.mapper.BrandMapper;
import com.bawei.hgshop.service.BrandService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Service(interfaceClass = BrandService.class)
public class BrandServiceImpl implements BrandService {
	
	@Autowired
	BrandMapper brandMapper;

	@Override
	public PageInfo<Brand> list(String brandName, int page, int pageSize) {
		// TODO Auto-generated method stub
		PageHelper.startPage(page, pageSize);
		
		return new PageInfo<Brand>(brandMapper.list(brandName));
	}

	@Override
	public int add(Brand brand) {
		// TODO Auto-generated method stub
		return brandMapper.add(brand);
		
	}

	@Override
	public int delBatch(int[] ids) {
		// TODO Auto-generated method stub
		return brandMapper.delBatch(ids);
	}

	@Override
	public Brand getById(int id) {
		// TODO Auto-generated method stub
		return brandMapper.findById(id);
	}

	@Override
	public int update(Brand brand) {
		// TODO Auto-generated method stub
		return brandMapper.update(brand);
	}

	/**
	 * 获取所有的品牌
	 */
	@Override
	public List<Brand> listAll() {
		// TODO Auto-generated method stub
		return brandMapper.list("");
	}

}
